#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int nums = 0;
    cin >> nums;
    vector<int> cost(nums, 0);

    int i = 0;
    for (i = 0; i < cost.size(); i++)
    {
        cin >> cost[i];
    }

    if (nums == 1)
    {
        cout << cost[0];
        return 0;
    }

    vector<int> res(nums+1, 0);

    for (i = 2; i < res.size(); i++)
    {
        res[i] = min(res[i - 2] + cost[i - 2], res[i - 1] + cost[i - 1]);
    }

    cout << res[i-1];
}